package com.woniuxy.Mapper;

import com.woniuxy.entity.ShopOrders;
import com.woniuxy.vo.AppointmentsVo;
import org.apache.ibatis.annotations.*;

@Mapper
public interface OrderMapper {
     @Select("SELECT so.*, a.schedule_id FROM shop_orders so " +
             "JOIN appointments a ON so.order_number = a.order_number " +
             "WHERE a.order_number = #{orderNumber}" +
             "AND so.status = #{status}")
     @Results({
             @Result(property = "orderNumber", column = "order_number"),
             @Result(property = "userId", column = "user_id"),
             @Result(property = "totalAmount", column = "total_amount"),
             @Result(property = "paymentAmount", column = "payment_amount"),
             @Result(property = "status", column = "status"),
             @Result(property = "paymentType", column = "payment_type"),
             @Result(property = "createTime", column = "create_time"),
             @Result(property = "payType", column = "pay_type"),
             @Result(property = "idCard", column = "id_card"),
             @Result(property = "scheduleId", column = "schedule_id") // 现在可以正确映射
     })
     AppointmentsVo getOrderByUserId(
             @Param("status") Integer status,
             @Param("orderNumber") String orderNumber);

     @Update("UPDATE shop_orders SET status = #{status} WHERE order_number = #{orderNumber}")
     int updateOrderStatus(@Param("orderNumber") Long orderNumber, @Param("status") Integer status);

}
